var app = getApp();
Page({
    data:{
        isinit : false,
        wxuser : false,
        status : 1,
        mess : '暂时无法绑定',
        scene : 0,
    },
    onLoad:function(options){
        var self = this;
        
        app.com.auth(function(user){
            self.setData({
                wxuser : user.wxInfo,
                scene : options.scene,
            });
            
            app.com.http('bindadmin','POST',{scene : options.scene},0,true,function(rea){
                if (!rea.data.message.errno) {
                    self.setData({
                        status : 3,
                        mess : '绑定管理员'
                    });
                }
            },function(rea){
                console.log( rea.data.errno );
                self.setData({
                    status : rea.data.errno,
                    mess : rea.data.message
                });
            });
        });
    },
    onShow: function () {
        var self = this;

    },
    onReady:function(){
        // 页面渲染完成
    },
    bind : function(){
        var self = this;
        app.com.http('bindadmin','POST',{scene : self.data.scene,op:'bind'},0,true,function(rea){
            if (!rea.data.message.errno) {
                wx.showModal({
                    title: '提示',
                    content: '已绑定',
                    showCancel : false,
                    success: function (res) {
                        self.setData({
                            status : 1,
                            mess : '绑定成功'
                        });
                    }
                })
            }
        });
    }
   
    
})